﻿#include "playvideo.h"
#include <QThread>
#include <QTime>
playVideo::playVideo(QString strUrl,QString strOut,QObject *parent):
    QObject(parent),
    m_strUrl(strUrl),
    m_strOut(strOut)
{
    pFFmpegMnger = new ffmpegMananger;
    connect(pFFmpegMnger,&ffmpegMananger::Sig_GetOneFrame,this,&playVideo::Sig_GetFrames);
}
playVideo::~playVideo()
{

}
void playVideo::setRecActive()
{
    emit this->recordFlag(true);
    printf("=================================true.\n");
}
void playVideo::setRecDeActive()
{
    emit this->recordFlag(false);
    printf("=================================false.\n");
}
void playVideo::playstart()
{
    std::cout<<"sun thread id = "<<QThread::currentThreadId()<<"\n";
    pFFmpegMnger->getRtspURL(m_strUrl);
    pFFmpegMnger->getOutURL(m_strOut);
    while(1)
    {
        if(pFFmpegMnger->ffmepgInput() == -138)//-138即断线错误号
        {
            QThread::sleep(5);//线程让出时间片，5秒以后尝试连接
            continue;
        }
        else
        {
            std::cout<<"显示错误返回错误\n";
            break;
        }
    }

    //pFFmpegMnger->test();
}

void playVideo::playstop()
{

}
